<template>
  <div>
    <el-table :data="recordData" border size="medium" style="width:100%">
      <el-table-column prop="userName" label="用户名" align="center"></el-table-column>
      <el-table-column prop="time" label="时间" align="center"></el-table-column>
      <el-table-column prop="operation" label="操作" align="center"></el-table-column>
    </el-table>
    <el-pagination
      style="margin-top: 1%"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="pageSizes"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalCount">
    </el-pagination>
  </div>
</template>

<script>
  import {recordService} from '../../../service/recordService'

  export default {
    name: 'historyRecord',
    data () {
      return {
        recordData: [],
        currentPage: 1,
        pageSizes: [10, 20, 30, 40],
        pageSize: 10,
        totalCount: 0,
      }
    },
    mounted () {
      this.findRecords()
    },
    methods: {
      handleSizeChange (val) {
        this.pageSize = val
        this.findRecords()
      },
      handleCurrentChange (val) {
        this.currentPage = val
        this.findRecords()
      },
      findRecords () {
        let pageDto = {currentPage: this.currentPage, pageSize: this.pageSize}
        recordService.findRecords(pageDto).then(res => {
          console.log(res.data)
          this.recordData = res.data.data
          this.totalCount = res.data.totalCount
        }).catch(error => {
          console.log(error)
        })
      }
    }

  }
</script>

<style lang="scss" scoped>

</style>
